package com.zzy.mccjt.exception;

import lombok.Getter;

/**
 * @program: mccjt-cloud
 * @description:
 * @author: zhouyang.zheng
 * @create: 2022-08-02 17:45
 **/
@Getter
public abstract class BaseException extends RuntimeException {
    /**
     * 异常信息
     */
    private String message;

    /**
     * 具体异常码
     */
    private int code;

    public BaseException(final int code, final String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BaseException(final int code, final String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
    }

    public BaseException(final int code, Throwable cause) {
        super(cause);
        this.code = code;
    }

    public BaseException(final int code, final String format, Object... args) {
        super(String.format(format, args));
        this.code = code;
        this.message = String.format(format, args);
    }

    public BaseException(final int code, Throwable cause, final String format, Object... args) {
        super(String.format(format, args), cause);
        this.code = code;
        this.message = String.format(format, args);
    }
}
